<template>
  <section :class="['main',{toggleMainL: open},{toggleMainR: openAside}]">
    <!-- <transition name="fade" mode="out-in"> -->
      <div :class="['mainLeft',{toggleMainLeft: sidebar}]">
        <sidebar>
        </sidebar>
      </div>
    <!-- </transition> -->
    <div :class="['mainCenter',{mainCenterToLeft: sidebar},{mainCenterToRight: sidebar}]">
      <!-- <transition name="fade" mode="out-in"> -->
        <router-view :key="key"></router-view>
      <!-- </transition> -->
    </div>
    <div :class="['mainRight',{toggleMainRight: sidebar}]">
      <sticky stickyTop="60" myheight="100%" zIndex="10">
        <aside-r></aside-r>
      </sticky>
      <span> </span>
    </div>
  </section>
</template>

<script>
import { mapGetters } from 'vuex'
import sidebar from '../Sidebar'
import asideR from '../Aside'
import Sticky from 'base/Sticky'
import ResizeMixin from 'common/mixin/ResizeHandler'
export default {
  name: 'AppMain',
  components: {
    sidebar,
    asideR,
    Sticky
  },
  mixins: [ResizeMixin],
  computed: {
    ...mapGetters([
      'device',
      'sidebar',
      'open',
      'openAside'
    ]),
    key() {
      return this.$route.name !== undefined ? this.$route.name + +new Date() : this.$route + +new Date()
    }
  }
}
</script>
<style lang="scss">
@import '~common/styles/variables.scss';
.main {
  display: flex;
  height: 100%;
  margin: 0 auto;
  max-width: $maxmainwidth;
  position: relative;
  transition: 'margin-left' 0.35s ease-out;
  .mainLeft {
    // position: relative;
    min-width: 180px;
    margin-right: 8px;
    width: 180px;
    height: 100%;
    transition: transform 0.35s ease-out;
  }
  .toggleMainLeft {
    // transform: translate3d(-188px, 0, 0);
    display: none;
  }
  .mainCenter {
    flex: 1;
    // max-width: 716px;
    height: 100%;
    margin-left: 0px;
    overflow: hidden;
    // transition: all 0.35s ease-out;
  }
  .mainCenterToLeft {
    // margin-left: -188px;
    max-width: none;
  }
  .mainCenterToRight {
    // margin-right: -248px;
  }
  .mainRight {
    width: 240px;
    margin-left: 8px;
    height: 100%;
    // transition: transform 0.35s ease-out;
  }
  .toggleMainRight {
    display: none;
    // transform: translate3d(248px, 0, 0);
  }
}
.toggleMainL {
  // margin-left: 188px;
  .toggleMainLeft {
    display: block;
    position: relative;
    .sidebar {
      background: #fff;
      position: fixed;
      top: 0;
      bottom: 0;
      width: 180px;
      z-index: 10;
      .nav-actived {
        background: rgba(25, 25, 25, 0.1);
      }
    }
  }
}
.toggleMainR {
  .toggleMainRight {
    display: block;
    position: absolute;
    .aside {
      background: #fff;
      position: fixed;
      top: 0;
      // bottom: 0;
      right: 0;
      z-index: 5;
      max-width: 240px;
      .aside-tool {
        background: #fff;
        height: 100%;
      }
      .category {
        background: #fff;
      }
    }
  }
}
</style>
